package com.macro.mall.portal.controller;


import com.macro.mall.common.api.CommonResult;
import com.macro.mall.model.UmsMember;
import com.macro.mall.portal.im.TxTemplate;
import com.macro.mall.portal.service.UmsMemberService;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;

@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/userSign")
public class AppUserSignController  {

    @Autowired
    private TxTemplate txTemplate;
    @Autowired
    private UmsMemberService memberService;

    /**
     * 获取用户的IM签名
     *
     * @return
     */
    @GetMapping("/sign")
    public CommonResult<HashMap<String, Object>> getUserSign() {
        UmsMember currentMember = memberService.getCurrentMember();
        HashMap<String, Object> map = new HashMap<>();
        map.put("userSign", txTemplate.getUserSign(currentMember.getId().toString()));
        return CommonResult.success(map);
    }
}
